package org.dawn.deveco.plugin.resourceeditor.test;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.dawn.deveco.plugin.resourceeditor.model.SimpleResourceContent;
import org.dawn.deveco.plugin.resourceeditor.model.item.SimpleItem;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.Vector;

public class Test {
    private static final Path resourcePath = Paths.get("E:\\StudyProjects\\HarmonyOS\\codelabs\\AlarmClock\\entry\\src\\main\\resources");

    public static void main(String[] args) {
        System.out.println("hello");
        try {
            final String path = "base\\element\\string.json";
//            String content = Files.readString(Paths.get(resourcePath.toString(), path), Charset.forName("UTF-8"));
            File file = Paths.get(resourcePath.toString(), path).toFile();
            ObjectMapper mapper = new ObjectMapper();
            Map<String, List<SimpleItem>> jsonMap = mapper.readValue(file, new TypeReference<>() {});
            SimpleResourceContent resourceContent = new SimpleResourceContent();
            for (Map.Entry<String, List<SimpleItem>> item: jsonMap.entrySet()) {
                resourceContent.addGroupData(item.getKey(), item.getValue());
            }
            Vector<Vector> tableContent = resourceContent.getJTableContent("string");
//            System.out.println(tableContent.category);
            System.out.println(tableContent);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
